package cn.edu.xmu.oomall.payment.model.bo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * 支付单
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class Payment {
    /**
     * 支付单状态
     */
    public enum State {
        OBLIGATION((byte)0, "待支付"),
        PAID((byte)1, "已支付"),
        CHECKED((byte)2, "已对账"),
        CLEARED((byte)3, "已清算"),
        FAILED((byte)4,"支付失败"),
        CANCELED((byte)5, "已取消");

        private static final Map<Byte, State> stateMap;

        static {
            stateMap = new HashMap();
            for (State enum1 : values()) {
                stateMap.put(enum1.code, enum1);
            }
        }

        private Byte code;
        private String description;

        State(Byte code, String description) {
            this.code = code;
            this.description = description;
        }

        public Byte getCode() {
            return this.code;
        }

        public String getDescription() {
            return this.description;
        }

        public State getDescriptionByCode(Integer code){
            return stateMap.get(code);
        }
    }

    private Long id;
    private String tradeSn;
    private Long patternId;
    private Long amount;
    private Long actualAmount;
    private String documentId;
    private Byte documentType;
    private LocalDateTime payTime;
    private LocalDateTime beginTime;
    private LocalDateTime endTime;
    private Byte state;
    private String descr;
    private Long adjustId;
    private String adjustName;
    private LocalDateTime adjustTime;
    private Long creatorId;
    private String creatorName;
    private Long modifierId;
    private String modifierName;
    private LocalDateTime gmtCreate;
    private LocalDateTime gmtModified;
}
